package designMode.compositePattern;

import java.util.Iterator;

/**
 * @author LIBOFEI
 * @ClassName MenuItem
 * @description 菜单项
 * @date 2020/6/28 13:52
 * @Version 1.0
 **/
public class MenuItem extends MenuComponent {
    private String name;
    private String description;
    private boolean vegetarian;
    private double price;

    public MenuItem(String name,String description,boolean vegetarian,double price){
        this.name = name;
        this.description = description;
        this.vegetarian = vegetarian;
        this.price = price;
    }


    @Override
    public String getName() {
        return name;
    }

    @Override
    public double getPrice() {
        return price;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public boolean isVegetarian() {
        return vegetarian;
    }

    @Override
    public void print() {
        System.out.print("itemName:" + getName());
        if(isVegetarian()){
            System.out.print("(V)");
        }
        System.out.println("," + getPrice());
        System.out.println("--" + getDescription());
    }

    @Override
    public Iterator createIterator() {
        return new NullIterator();
    }
}
